<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="com.corn.entity.User" %><%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2025/2/5
  Time: 13:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>$Title$</title>
  </head>
  <body>
  <%--JSP声明，定义Java方法--%>
  <%!
    public String test(){
      return "Hello World!";
    }
  %>
  <%--  JSP脚本，执行Java逻辑代码--%>
  <%
    System.out.println(test());
  %>
  <%
    String str = test();
  %>
<%--  JSP表达式，把Java对象直接输出到HTML页面中--%>
  <%=str%>

  <%
    List<User> list = new ArrayList<>();
    list.add(new User("张三",22));
    list.add(new User("李四",21));
    list.add(new User("王五",23));
  %>
  <table>
    <tr>
      <th>姓名</th>
      <th>年龄</th>
    </tr>
    <%
      for (int i = 0;i<list.size();i++){
    %>
    <tr>
      <td><%=list.get(i).getName()%></td>
      <td><%=list.get(i).getAge()%></td>
    </tr>
    <%
      }
    %>
  </table>
  </body>
</html>
